package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.assistant.core.exception.AppException;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.dataStatistics.enroll.EnrollStudentQueryVO;
import com.jwsoft.manager.common.vo.eduAddress.SchoolAddressQueryVO;
import com.jwsoft.manager.common.vo.eduStudentTj.*;
import com.jwsoft.manager.core.integration.EduStudentTjIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 学生调剂信息网关
 *
 * @author zhiyuan
 * @since 2023-03-13
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "学生调剂信息", description = "学生调剂信息")
public class EduStudentTjController {

    @Autowired
    public EduStudentTjIntegration eduStudentTjIntegration;

    @Operation(summary = "学生调剂信息分页查询",description = "学生调剂信息分页查询")
    @PostMapping(value = "/studentTj0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduStudentTjVO>> getList(@RequestBody @Validated EduStudentTjQueryVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.getList(vo));
    }

    @Operation(summary = "学生调剂信息根据主键查询详情",description = "学生调剂信息根据主键查询详情")
    @PostMapping(value = "/studentTj0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduStudentTjVO> getById(@RequestBody @Validated EduStudentTjKeyVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学生调剂信息新增",description = "学生调剂信息新增")
    @PostMapping(value = "/studentTj0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduStudentTjVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduStudentTjVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学生调剂信息修改",description = "学生调剂信息修改")
    @PostMapping(value = "/studentTj0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduStudentTjVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduStudentTjVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.edit(vo));
    }

    @Idempotent(expire = "PT2S") //2秒内防重复提交
    @Operation(summary = "学生调剂信息删除", description = "学生调剂信息删除")
    @PostMapping(value = "/studentTj0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduStudentTjKeyVO vo) {
        eduStudentTjIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "家长端提交调剂申请", description = "家长端提交调剂申请")
    @PostMapping(value = "/studentTj0007", produces = "application/json;charset=UTF-8")
    public AppResponse saveApply(@RequestBody @Validated EduStudentTjApplyVO vo) {
        eduStudentTjIntegration.saveApply(vo);
        return AppResponse.successMsg("保存成功！");
    }

    @Operation(summary = "学生调剂分页查询（管理端/学校端）接口", description = "学生调剂分页查询（管理端/学校端）接口")
    @PostMapping(value = "/studentTj0008", produces = "application/json;charset=UTF-8")
    public  AppResponse<PageInfo<EduStudentTjVO>> queryStudentTj(@RequestBody @Validated EduStudentTjQueryVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.queryStudentTj(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学生调剂数据审核", description = "学生调剂数据审核")
    @PostMapping(value = "/studentTj0009", produces = "application/json;charset=UTF-8")
    public AppResponse auditStudentTj(@RequestBody @Validated EduStudentTjVO vo) {
        eduStudentTjIntegration.auditStudentTj(vo);
        return AppResponse.successMsg("学生调剂数据审核成功");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "家长调剂数据驳回到待审核（管理员）", description = "家长调剂数据驳回到待审核（管理员）")
    @PostMapping(value = "/studentTj0010", produces = "application/json;charset=UTF-8")
    public AppResponse rejectedToReview(@RequestBody @Validated EduStudentTjRejectedVO vo) {
        eduStudentTjIntegration.rejectedToReview(vo);
        return AppResponse.successMsg("驳回到待审核成功");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "撤回学校调剂数据（管理员）", description = "撤回学校调剂数据（管理员）")
    @PostMapping(value = "/studentTj0011", produces = "application/json;charset=UTF-8")
    public AppResponse withdrawSchoolTj(@RequestBody @Validated EduStudentTjRejectedVO vo) {
        eduStudentTjIntegration.withdrawSchoolTj(vo);
        return AppResponse.successMsg("驳回到待审核成功");
    }
    @Operation(summary = "学校调剂情况统计", description = "学校调剂情况统计")
    @PostMapping(value = "/studentTj0012", produces = "application/json;charset=UTF-8")
    public  AppResponse<PageInfo<EduStudentTjStatisticsVO>> queryTjStatistics(@RequestBody @Validated EduStudentTjQueryVO vo) {
        return AppResponse.successData(eduStudentTjIntegration.queryTjStatistics(vo));
    }



    @PostMapping(value = "/studentTj0013", produces = "application/json;charset=UTF-8")
    @Operation(summary = "学校调剂数据导出", description = "学校调剂数据导出")
    @NoSignCrypto
    public void exportTjData(@RequestBody @Validated EduStudentTjQueryVO vo, HttpServletResponse response) {
        eduStudentTjIntegration.exportTjData(vo,response);
    }


}
